﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="jnagr.Web.sicpet.List" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <style type="text/css">
        .fite {
            margin-left: 4px;
        }

            .fite label {
                width: 100px;
                float: left;
                line-height: 35px;
            }
    </style>

    <script type="text/javascript">
        var abh = "";
        var level;
        var pt;
        var uid = "";
        var map;
        var data_info;
        var opts;
        var isone = "";
        $(function () {
            InitTree();
            InitSearch();
        });

        function getQueryParams(queryParams) {
            queryParams.abh = abh;
            return queryParams;

        }
        //增加查询参数，重新加载表格  
        function reloadgrid() {
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');
        }

        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '靶标害虫列表', //表格标题
                url: qxurl + '/sys/ashx/Username.ashx', //请求数据的页面
                sortName: 'devID', //排序字段
                idField: 'KeyId', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '95%', //宽度
                height: '95%', //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: true,
                method: 'post',
                columns: [[
                    { title: '设备编号', field: 'DevID', width: 60, sortable: true },
	                //{ title: '设备名称', field: '', width: 80 },
                    {
                        title: '虫情', field: 'a', width: 280, formatter: function (v, d, i) {
                            var r = "";
                            if (d.chn0 != "" && d.chn0 != null) r = r + d.chn0 + "(" + d.ch0 + ")";
                            if (d.chn1 != "" && d.chn1 != null) r = r + d.chn1 + "(" + d.ch1 + ")";
                            if (d.chn2 != "" && d.chn2 != null) r = r + d.chn2 + "(" + d.ch2 + ")";
                            if (d.chn3 != "" && d.chn3 != null) r = r + d.chn3 + "(" + d.ch3 + ")";
                            return r;
                        }
                    },
                    { title: '单位名称', field: 'DevOwnerName', width: 120 },
                    { title: '更新时间', field: 'updateTime', width: 120, sortable: true },
                    { title: '负责人', field: 'UserName', width: 60 },
                    { title: '地址', field: 'DevLocation', width: 220 },
                    {
                        title: '历史状态', field: 'v', width: 80, formatter: function (v, d, i) {
                            return '<a href="#" onclick="top.addTab(\'靶标' + d.UserName + '\',\'../weatherinfo/ybqshow.aspx?uid=' + d.KeyId + '\', \'icon icon-server\');">详情</a>';

                        }
                    }
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "myybq", "abh": abh },
                pageNumber: 1, //默认索引页
                pageSize: 200, //默认一页数据条数
                rownumbers: true, //行号
                pageList: [10, 20, 50, 200, 500],
                loader: function (param, success, error) {
                    $.ajax({
                        url: qxurl + '/sys/ashx/Username.ashx',
                        dataType: 'jsonp',
                        success: function (data) {
                            success(data);
                        },
                        error: function (xhr) { error(xhr.responseText) }
                    });
                },
                pagination: true
            });
        }

        function InitSearch() {
            $("#ipt_search").searchbox({
                width: 140,
                searcher: function (val, name) {
                    var queryParams = $('#tt').datagrid('options').queryParams;
                    getQueryParams(queryParams);
                    $('#tt').datagrid('options').queryParams = queryParams;
                    $('#tt').datagrid('options').queryParams.search_type = name;
                    $('#tt').datagrid('options').queryParams.search_value = val;
                    $('#tt').datagrid('reload');
                },
                prompt: '查询信息'
            });
        }
        function InitTree() {
            $('#pt').tree({
                width: '100%', //宽度                
                lines: true,
                //data: provincetree,   
                url: '../areainfo/GetArea.ashx', //请求数据的页面 
                method: 'post',
                queryParams: { "action": "querymyareauser" },
                onBeforeExpand: function (node) {
                    $("#pt").tree("options").queryParams = { "action": "queryyb9" };
                    $('#pt').tree('options').url = "../areainfo/GetArea.ashx?pid=" + node.id;
                },
                onClick: function (node) {
                    if (node.text != "") {
                        abh = node.bm;
                        reloadgrid();
                    }
                },
                onLoadSuccess: function (node, param) {
                    if (isone == "") {
                        var node = $('#pt').tree('getRoot');
                        abh = node.bm;
                        InitGird();
                        isone = "OK";
                    }
                }
            });

        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="easyui-layout" style="width: 100%; height: 100%;" id="mycon">
        <div region="west" split="true" title="区域检索" style="width: 180px; overflow: scroll" id="west">
            <ul id="pt"></ul>
        </div>
        <div region="center" style="background: #eee; overflow: auto">
            <table id="tt"></table>
        </div>
    </div>

    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                <td style="text-align: right; padding-right: 15px">

                    <input id="ipt_search" menu="#search_menu" />
                    <div id="search_menu" style="width: 80px">
                        <div name="usernum">
                            用户名
                        </div>
                        <div name="username">
                            姓 名
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>

